﻿using ProjectGamer.DataModels;
using ProjectGamer.Data;
using ProjectGamer.Web.DbAdapters.IAdapters;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace ProjectGamer.Web.DbAdapters.Adapters
{
    public class AzAdapter : IAzAdapter
    {

        public List<AzGame> GetAllGames()
        {
            List<AzGame> azGames = new List<AzGame>();
            using (ApplicationDbContext db = new ApplicationDbContext())
            {
                azGames = db.AzGames.ToList();
            }
            return azGames;
        }

        public List<AzGame> GameSearch(string search)
        {
            List<AzGame> azGames = new List<AzGame>();
            using (ApplicationDbContext db = new ApplicationDbContext())
            {
                azGames = db.AzGames.Where(x => x.Title.Contains(search)).ToList();
            }
            return azGames;
        }


        public AzGame GetGameById(string id)
        {
            AzGame azGame;
            using (ApplicationDbContext db = new ApplicationDbContext())
            {
                azGame = db.AzGames.Where(x => x.Id == id).FirstOrDefault();
            }
            return azGame;
        }
    }
}